<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <p v-if="isLogin">{{username}}</p>
        <button v-else v-on:click="login">请登陆</button>
    </div>
    <script src="./vue.js"></script>
    <script>
        var Toggle = {
            data() {
                return {
                    username: '爱学习的小刘',
                    isLogin: false
                }
            },
            // 所有的函数都在methods中
            methods: {
                // 登陆的函数
                login() {
                    this.isLogin = true;
                }
            }
        }
        Vue.createApp(Toggle).mount('#app');
    </script>
</body>
</html>